package com.bbc.action.type;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.bbc.base.BaseAction;
import com.bbc.entity.type.TypeInfo;
import com.bbc.entity.type.TypeQuery;
import com.bbc.service.type.TypeService;

public class TypeAction extends BaseAction {

	private static final long serialVersionUID = 1L;
	private TypeInfo typeInfo;
	private TypeQuery query;
	private List<TypeInfo> typeInfos;
	
	@Autowired
	private transient TypeService typeService;
	
	public String addType() {
		int id = typeService.addType(typeInfo);
		System.out.println("addtype:typeid:"+id);
		return list();
	}
	
	public String addtbType() {
		typeService.addtbType("0");
		return list();
	}
	
	public String list() {
		if (query == null) {
			query = new TypeQuery();
		}
		typeInfos = typeService.findType(query,page,20);
		return SUCCESS;
	}

	public TypeInfo getTypeInfo() {
		return typeInfo;
	}

	public void setTypeInfo(TypeInfo typeInfo) {
		this.typeInfo = typeInfo;
	}

	public TypeQuery getQuery() {
		return query;
	}

	public void setQuery(TypeQuery query) {
		this.query = query;
	}

	public List<TypeInfo> getTypeInfos() {
		return typeInfos;
	}

	public void setTypeInfos(List<TypeInfo> typeInfos) {
		this.typeInfos = typeInfos;
	}

}
